﻿package uiresource.map
{
    import com.core.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
    import manager.*;
    import morn.core.components.*;
    import plugin.bagN.*;

    public class CityPointUI extends View
    {
        public var img:UrlImage;
        public var btn:UrlImage;
        public var _curer:UrlImage;
        private const _url1:String = "cs2_mapasset/";
        private const _url2:String = ".png";
        private var mSelectedFilter:DropShadowFilter;
        public var data:Object = null;

        public function CityPointUI(param1:Object)
        {
            this.data = param1;
            if (this.img)
            {
                this.img.url = this._url1 + this.data.icon + this._url2;
            }
            return;
        }// end function

        override protected function createChildren() : void
        {
            loadUI("CityPoint.xml");
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            if (this.data)
            {
                this.img.url = this._url1 + this.data.icon + this._url2;
            }
            this.btn.visible = false;
            this.btn.addEventListener(MouseEvent.CLICK, this.btnHandler);
            this.addEventListener(MouseEvent.ROLL_OVER, this.rolloverHandler);
            this.addEventListener(MouseEvent.ROLL_OUT, this.rollountHandler);
            return;
        }// end function

        protected function rolloverHandler(event:MouseEvent) : void
        {
            var _loc_2:* = this.data.tips2;
            var _loc_3:* = _loc_2.split("#");
            var _loc_4:* = this.data.name + "\n" + this.data.tips1 + "\n";
            var _loc_5:int = 0;
            while (_loc_5 < _loc_3.length)
            {
                
                _loc_4 = _loc_4 + _loc_3[_loc_5];
                _loc_5++;
            }
            ModelProxy.change("tips", "normal", {p:new Point(this.stage.mouseX, this.stage.mouseY), data:_loc_4});
            if (this.mSelectedFilter == null)
            {
                this.mSelectedFilter = new DropShadowFilter(0, 45, MColor.T_YELLOW, 0.5, 6, 6, 4, 8);
            }
            this.img.filters = [this.mSelectedFilter];
            if (!this.btn.visible)
            {
                this.showBtn();
                ModelProxy.change("minimap", "showpass", this.data.name);
            }
            return;
        }// end function

        protected function rollountHandler(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "state", "close");
            this.img.filters = [];
            return;
        }// end function

        protected function btnHandler(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "state", "close");
            var _loc_2:* = ModelProxy.getValue("data", "ringdata");
            if (_loc_2 && _loc_2[0] >= 7)
            {
                PluginManager.instance.sendToServer("bag", CMDBag.NPCDeliver, this.data.mapid);
            }
            return;
        }// end function

        public function closeBtn() : void
        {
            this.btn.visible = false;
            return;
        }// end function

        public function updatecur() : void
        {
            this._curer.visible = ModelProxy.getValue("data", "user.stageid") == this.data.mapid;
            return;
        }// end function

        private function showBtn() : void
        {
            this.btn.visible = true;
            return;
        }// end function

    }
}
